package com.gdougms.mapper;

import com.gdougms.entity.Equipment;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;
import java.util.List;

@Mapper
public interface EquipmentMapper {

    //获取所有器材
    @Select("select * from equipment where state != 0")
    List<Equipment> equipList();

    //获取名称为“xxx（如篮球）”的所有信息
    @Select("select * from equipment where name like CONCAT('%',#{name},'%') and state!=0")
    List<Equipment> getEquipByName(String name);

    //添加器材
    @Insert("insert into equipment(name, number, cost, remark) values(#{name}, #{number}, #{cost}, #{remark})")
    int addEquip(String name, Integer number, BigDecimal cost, String remark);

    //根据id删除器材
    @Update("update equipment set state=0 where id=#{id}")
    int deleteEquipById(Integer id);

    //根据id修改器材信息，在EquipmentMapper.xml中已经配置
    int updateEquipById(Integer id, String name, Integer number, BigDecimal cost, String remark);

    //获取所有器材（类型）的名字
    @Select("select DISTINCT name from equipment where state != 0")
    List<String> getAllEquipName();

    //获取表中所有器材的收费标准
    @Select("select DISTINCT cost from equipment where state != 0")
    List<BigDecimal> getAllEquipCost();

}
